﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ConsoleApp10
{
    public class OrderDetails
    {
        public int ID { get; set; }
        private int num;
        public int idofDetails { get; set; }
        private Goods Goods;

        [ForeignKey("Order")]
        public int OrderId { get; set; }
        public virtual Order Order { get; set; }
        public OrderDetails()
        {
            Goods = new Goods("",0);
            num = 0;
        }
        public OrderDetails(Goods a,int n)
        {
            Goods = a;
            num = n;
        }
        public override bool Equals(object obj)
        {
            OrderDetails m = obj as OrderDetails;
            return m != null && m.Goods == Goods && m.num == num;
        }
        public override string ToString()
        {
            string str = "";
            str = Goods.ToString() + "  数量：" + num + "\n";
            return str;
        }
        public double GetCost()
        {
            return num * Goods.price;
        }
        public Goods GetGoods()
        {
            return Goods;
        }
        public void SetNum(int n)
        {
            num = n;
        }
        public int GetNum()
        {
            return num;
        }
    }
    public class Goods
    {
        public int ID { get; set; }
        public string name { get; set; }
        public double price { get; set; }
        public OrderDetails details { get; set; }
        public Goods()
        {
            name = "";
            price = 0;
        }
        public Goods(string str, double num)
        {
            name = str;
            price = num;
        }
        public override string ToString()
        {
            return name + "  单价：" + price;
        }
    }
}
